package com.gst.handfood.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;

import com.gst.handfood.utils.AppManger;

import butterknife.ButterKnife;

/**
 * Created by YBH on 2017/10/31.
 */

public abstract class BaseActivity extends FragmentActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        ButterKnife.bind(this);
        AppManger.getInstance().addActivity(this);
        initTitle();
        initData();
    }
    /**
     * 关闭当前页面
     */
    public void closeCurentActivity(){
        AppManger.getInstance().removeCurrent();
    }

    /**
     * 跳转到指定Activity
     * @param clasz
     * @param bundle
     */
    public void gotoActivity(Class clasz,Bundle bundle){
        Intent intent = new Intent(this,clasz);
        if (bundle!=null) {
            intent.putExtra("param",bundle);
        }
        startActivity(intent);
    }

    protected abstract void initData();

    protected abstract void initTitle();

    public abstract int getLayoutId();
}
